package com.cuitrip.business.order.detail.ui.viewholder;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.cuitrip.app.base.PartViewHolder;
import com.cuitrip.business.order.detail.ui.model.SimpleServicePartRenderData;
import com.cuitrip.business.tripservice.ServiceDetailActivity;
import com.cuitrip.service.R;
import com.cuitrip.util.track.TrackUtil;
import com.lab.utils.ImageHelper;

import butterknife.ButterKnife;
import butterknife.Bind;

/**
 * 簡便型行程viewholder
 * Created by ak
 */
public class SimpleServicePartViewHolder implements PartViewHolder<SimpleServicePartRenderData> {
    public static final int RES = R.layout.simple_service_part;

    @Bind(R.id.ct_service_layout)
    View mServiceLayout;


    @Bind(R.id.ct_service_name_tv)
    TextView mServiceNameTv;

    @Bind(R.id.service_pic)
    ImageView mServicePic;

    @Bind(R.id.ct_service_address_tv)
    TextView mServiceAddress;

    public void build(View view) {
        ButterKnife.bind(this, view);
    }

    public void render(final SimpleServicePartRenderData data) {
        mServiceNameTv.setText(data.getServiceName());
        ImageHelper.displayCtImage(data.getServicePic(), mServicePic, ImageHelper.getCtDisplayImageOptions());
        mServiceAddress.setText(data.getAddress());
        mServiceLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                TrackUtil.trackScreenName("/booking/summary/snapshot/" + data.getStatus());
                ServiceDetailActivity.start(v.getContext(), data.getOid(), ServiceDetailActivity.SNAPSHOT);
            }
        });
    }


}
